package club.easin.sq.ctl;

import club.easin.common.DatagridRequestDto;
import club.easin.pow.dto.UserSession;
import club.easin.sq.bl.Housebl;
import club.easin.sq.dao.SqHouseMapper;
import club.easin.sq.dto.HouseQueryDto;
import club.easin.sq.dto.SqHouse;
import club.easin.utils.ReturnDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("house")
public class HouseCtl {
    @Autowired
    private Housebl housebl;

    @RequestMapping("addhouse")
    @ResponseBody
    public ReturnDto addhouse(UserSession userSession,@RequestBody SqHouse sqHouse){
        return housebl.addHouse(userSession,sqHouse);
    }

    @RequestMapping("delhouse")
    @ResponseBody
    public ReturnDto delhouse(UserSession userSession,String houseid){
        return housebl.delHouse(houseid);
    }

    @RequestMapping("edithouse")
    @ResponseBody
    public ReturnDto edithouse(UserSession userSession,@RequestBody SqHouse sqHouse){
        return housebl.editHouse(sqHouse);
    }

    @RequestMapping("houseGrild")
    @ResponseBody
    public ReturnDto getHouseGrild(UserSession userSession, DatagridRequestDto<HouseQueryDto> dto){
        return housebl.houseGrild(dto);
    }

    @RequestMapping("addInmateidToHouse")
    @ResponseBody
    public ReturnDto addInmateidToHouse(UserSession userSession,String houseid,String inmateid){
        return housebl.addInamteToHouse(houseid,inmateid);
    }

    @RequestMapping("getHouseInmate")
    @ResponseBody
    public ReturnDto getHouseInmate(String houseid){
        return housebl.getInamteByHouse(houseid);
    }
    @RequestMapping("delInmateByHouse")
    @ResponseBody
    public ReturnDto delInmateByHouse(UserSession userSession,String houseid,String inmateid){
        return housebl.delHouseInmate(houseid,inmateid);
    }

}
